﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ZFSDomain.ViewModel.Step
{
    public class SkinViewModel : ViewModelBase
    {
        public SkinViewModel()
        {
            Swatches = new SwatchesProvider().Swatches;
        }

        /// <summary>
        /// 样式集合
        /// </summary>
        public IEnumerable<Swatch> Swatches { get; }

        private RelayCommand<Swatch> _applyCommand;

        /// <summary>
        /// 设置样式命令
        /// </summary>
        public RelayCommand<Swatch> ApplyCommand
        {
            get
            {
                if (_applyCommand == null)
                {
                    _applyCommand = new RelayCommand<Swatch>(o => Apply(o));
                };
                return _applyCommand;
            }
            set
            {
                _applyCommand = value;
            }

        }

        /// <summary>
        /// 设置样式
        /// </summary>
        /// <param name="swatch"></param>
        private void Apply(Swatch swatch)
        {
            new PaletteHelper().ReplacePrimaryColor(swatch);
        }

        /// <summary>
        /// 设置默认样式
        /// </summary>
        /// <param name="swatch"></param>
        public void ApplyDefault()
        {
            new PaletteHelper().ReplacePrimaryColor(Swatches.FirstOrDefault(t => t.Name.Equals("blue")));
        }

    }

}
